package com.atguigu.rabbit.consumer.listener.annotation;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @Author: Worker Hu
 * @CreateTime: 2024-07-23  18:25
 */
@Component
public class RabbitListener01 {

    @RabbitListener(bindings = @QueueBinding(value = @Queue(value = "toplic_queue03", durable = "true"),
            exchange = @Exchange(value = "topic_exchange02",durable = "true",type = ExchangeTypes.TOPIC),
    key = {"error","info"})
    )
    public void TopicQueue(Message message){
        byte[] body = message.getBody();
        String msg = new String(body);
        System.out.println("测试RabbitListener声明队列、交换机、绑定信息"+msg);
    }
}


